<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-doctest.html" />
<link rel="prev" href="development.html" />
<link rel="parent" href="development.html" />
<link rel="next" href="module-doctest.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>23.1 pydoc -- Documentation generator and online help system</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="23. development Tools"
  href="development.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="23. development Tools"
  href="development.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="23.2 doctest  "
  href="module-doctest.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="development.html">23. Development Tools</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="development.html">23. Development Tools</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-doctest.html">23.2 doctest  </a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h1><a name="SECTION0025100000000000000000">
23.1 <tt class="module">pydoc</tt> --
         Documentation generator and online help system</a>
</h1>

<p>
<a name="module-pydoc"></a>

<p>

<span class="versionnote">New in version 2.1.</span>

<a id='l2h-4935' xml:id='l2h-4935'></a>

<p>
The <tt class="module">pydoc</tt> module automatically generates documentation from
Python modules.  The documentation can be presented as pages of text
on the console, served to a Web browser, or saved to HTML files.

<p>
The built-in function <tt class="function">help()</tt> invokes the online help system
in the interactive interpreter, which uses <tt class="module">pydoc</tt> to generate
its documentation as text on the console.  The same text documentation
can also be viewed from outside the Python interpreter by running
<b class="program">pydoc</b> as a script at the operating system's command prompt.
For example, running

<p>
<div class="verbatim"><pre>
pydoc sys
</pre></div>

<p>
at a shell prompt will display documentation on the <tt class="module"><a href="module-sys.html">sys</a></tt>
module, in a style similar to the manual pages shown by the <span class="Unix">Unix</span>
<b class="program">man</b> command.  The argument to <b class="program">pydoc</b> can be the name
of a function, module, or package, or a dotted reference to a class,
method, or function within a module or module in a package.  If the
argument to <b class="program">pydoc</b> looks like a path (that is, it contains the
path separator for your operating system, such as a slash in <span class="Unix">Unix</span>),
and refers to an existing Python source file, then documentation is
produced for that file.

<p>
Specifying a <b class="programopt">-w</b> flag before the argument will cause HTML
documentation to be written out to a file in the current directory,
instead of displaying text on the console.

<p>
Specifying a <b class="programopt">-k</b> flag before the argument will search the
synopsis lines of all available modules for the keyword given as the
argument, again in a manner similar to the <span class="Unix">Unix</span> <b class="program">man</b>
command.  The synopsis line of a module is the first line of its
documentation string.

<p>
You can also use <b class="program">pydoc</b> to start an HTTP server on the local
machine that will serve documentation to visiting Web browsers.
<b class="program">pydoc</b> <b class="programopt">-p 1234</b> will start a HTTP server on port
1234, allowing you to browse the documentation at
<code>http://localhost:1234/</code> in your preferred Web browser.
<b class="program">pydoc</b> <b class="programopt">-g</b> will start the server and additionally
bring up a small <tt class="module"><a href="module-Tkinter.html">Tkinter</a></tt>-based graphical interface to help
you search for documentation pages.

<p>
When <b class="program">pydoc</b> generates documentation, it uses the current
environment and path to locate modules.  Thus, invoking
<b class="program">pydoc</b> <b class="programopt">spam</b> documents precisely the version of
the module you would get if you started the Python interpreter and
typed "<tt class="samp">import spam</tt>".

<p>
Module docs for core modules are assumed to reside in
<a class="url" href="http://www.python.org/doc/current/lib/">http://www.python.org/doc/current/lib/</a>.  This can be overridden by
setting the <a class="envvar" id='l2h-4936' xml:id='l2h-4936'>PYTHONDOCS</a> environment variable to a different URL or
to a local directory containing the Library Reference Manual pages.

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="23. development Tools"
  href="development.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="23. development Tools"
  href="development.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="23.2 doctest  "
  href="module-doctest.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="development.html">23. Development Tools</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="development.html">23. Development Tools</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-doctest.html">23.2 doctest  </a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
